# -*- coding: utf-8 -*-
# @Time :    2022/6/12 17:48
# @Author :  jia
# @File :    ios_location
# @Project : appium
# @Description:
"""
appium1.22版本提示
[Deprecated] Please use 'find_element' with 'AppiumBy.IOS_PREDICATE' instead.
定位写法要求如下
driver.find_element(AppiumBy.IOS_PREDICATE, "label == '中国 (+86)'")
"""
from Common import driver_iphone
from appium.webdriver.common.appiumby import AppiumBy


driver = iphone.desired()
# ios_predicate 定位 （推荐使用）
driver.find_element(AppiumBy.IOS_PREDICATE, "label == '中国 (+86)'")
driver.find_element_by_ios_predicate("label == '我的钱包'")
driver.find_element_by_ios_predicate("label CONTAINS '测试'")  # 包含
driver.find_element_by_ios_predicate("label like '测试'")  # 模糊查找
driver.find_element_by_ios_predicate("name > 100 ")  # 数值比较
driver.find_element_by_ios_predicate("name IN {'Alan','May'}")  # in
driver.find_element_by_ios_predicate("label BEGINSWITH '420'")  # 以字符串420开头
driver.find_element_by_ios_predicate("type == XCUIElementTypeStaticText AND label CONTAINS '测试'")  # 两种元素定位

# accessibility_id定位，等同于by_name（推荐使用）
driver.find_element(AppiumBy.ACCESSIBILITY_ID, 'WBPageDiscoverSubGirdView')
driver.find_element_by_accessibility_id('WBPageDiscoverSubGirdView')

# class_name定位，不推荐使用
driver.find_element_by_class_name('XCUIElementTypeButton')

# x-path定位
driver.find_element_by_xpath("className/className/className/className")  # 绝对路径定位
driver.find_element_by_xpath("/className")          # 相对路径定位
driver.find_element_by_xpath("//className[index]")  # 元素索引定位
driver.find_element_by_xpath("//className[@label='更多信息']")  # 属性定位
driver.find_element_by_xpath("//className[@label='更多信息'][@isVisible='1']")  # 两种属性定位
driver.find_element_by_xpath("//className[contains(@label,'更多')]")           # 包含属性定位

# IOS_UIAUTOMATION
driver.find_element(AppiumBy.IOS_UIAUTOMATION, '')

# 收起键盘
driver.hide_keybord()








